<?php
/* ========== ########## ========== ########## ========== ########## ========== */
/*                                                                              */
/*   WHMCS v4.1.2 NULLED R4 by FLIPMODE  [ BAD SYNTAX ]                         */
/*                                                                              */
/*                             INTERNAL BAD SYNTAX NULLED VERSION: 2.5.9.6 R4   */
/*                                                                              */
/*   ALL files have been analysed, cleaned and nulled of:                       */
/*     - Call Backs  (100%)                                                     */
/*     - Link Backs (95%)                                                       */
/*     - Licensing  (100%)                                                      */
/*     - Remote Links + URL's                                                   */
/*                                                                              */
/*   WHMCS v4.1.2 RELEASED: 4th November 2009                                   */
/*    -> FIRST v4.1.2 NULL R1: 19th November 2009                               */
/*    -> UPDATED v4.1.2 NULL R4: 27th November 2009                             */
/*                                                                              */
/*   TESTING + VERIFICATION::                                                   */
/*     Files Cleaned, Nulled, Checked, Verified By:                             */
/*      -> FLIPMODE!                                                            */
/*     Decoded By:                                                              */
/*      -> FLIPMODE! + Unknown Decoder                                          */
/*     Tested By:                                                               */
/*      -> FLIPMODE!, LeetWolf, and 12 Anonymous Users...                       */
/*     WHMCS 4.1.2 Supplied By:                                                 */
/*      -> WHM CompleteShit Coder @ WHMCS.com                                   */
/*                                                                              */
/*                                                                              */
/*   IMPORTANT NOTE::                                                           */
/*   PLEASE NOTE THIS IS FOR TRIAL PURPOSES ONLY!                               */
/*                          LIKE IT? THEN BUY IT!                               */
/*                                                                              */
/* ========== ########## ========== ########## ========== ########## ========== */


require '../dbconnect.php';
require '../includes/functions.php';
require '../includes/adminfunctions.php';
$aInt = new adminInterface ('Database Status');
$aInt->title = 'Database Status';
$aInt->sidebar = 'utilities';
$aInt->icon = 'dbbackups';
$aInt->requiredFiles (array ('backupfunctions'));
if ($optimize)
{
	$alltables = mysql_query ('SHOW TABLES');
	while ($table = mysql_fetch_assoc ($alltables))
	{
		foreach ($table as $db => $tablename)
		{
			mysql_query ('OPTIMIZE TABLE \'' . $tablename . '\'');
		}
	}

	infobox ('Optimization Complete', 'All database tables successfully optimized!');
}

if ($dlbackup)
{
	set_time_limit (0);
	header ('Content-type: application/octet-stream');
	header ('Content-disposition: attachment; filename=' . $db_name . '_backup_' . date ('Ymd_His') . '.zip');
	echo generatebackup ();
}

ob_start ();
echo $infobox;
echo '
<table width=760 align=center cellspacing=0 cellpadding=0><tr><td width=380 valign=top>

<table bgcolor=#cccccc cellspacing=1 width=370 align=center>
<tr style="text-align:center;font-weight:bold;background-color:#efefef"><td>Name</td><td>Rows</td><td>Size</td></tr>
';
$query = 'SHOW TABLE STATUS';
$result = mysql_query ($query);
$i = 0;
while ($data = mysql_fetch_array ($result))
{
	$name = $data['Name'];
	$rows = $data['Rows'];
	$datalen = $data['Data_length'];
	$indexlen = $data['Index_length'];
	$totalsize = $datalen + $indexlen;
	$totalrows += $rows;
	$size += $totalsize;
	$reportarray[] = array ('name' => $name, 'rows' => $rows, 'size' => round ($totalsize / 1024, 2));
	++$i;
}

foreach ($reportarray as $key => $value)
{
	if ($key < $i / 2)
	{
		echo '<tr bgcolor=#ffffff style="text-align:center"><td>' . $value['name'] . '</td><td>' . $value['rows'] . '</td><td>' . $value['size'] . ' Kb</td></tr>';
		continue;
	}
}

echo '</table>

</td><td align="center" width=370 valign=top>

<table bgcolor=#cccccc cellspacing=1 width=370>
<tr style="text-align:center;font-weight:bold;background-color:#efefef"><td>Name</td><td>Rows</td><td>Size</td></tr>
';
foreach ($reportarray as $key => $value)
{
	if ($i / 2 <= $key)
	{
		echo '<tr bgcolor=#ffffff style="text-align:center"><td>' . $value['name'] . '</td><td>' . $value['rows'] . '</td><td>' . $value['size'] . ' Kb</td></tr>';
		continue;
	}
}

echo '</table>

</td></tr></table>

<p align=center><b>Total Tables:</b> ';
echo $i;
echo ' - <b>Total Rows:</b> ';
echo $totalrows;
echo ' - <B>Total Size:</B> ';
echo round ($size / 1024, 2);
echo ' Kb</p>

<p align=center><input type="button" value="Optimize Tables" class="button" onClick="window.location=\'systemdatabase.php?optimize=true\'"> <input type="button" value="Download Database Backup" class="button" onClick="window.location=\'systemdatabase.php?dlbackup=true\'"></p>

</td></tr></table>

';
$content = ob_get_contents ();
ob_end_clean ();
$aInt->content = $content;
$aInt->display ();
?>